package com.example.demo.mythread;

public class MyThread extends Thread{
    int i = 0;
    @Override
    public void run(){
        System.out.println("启动线程"+Thread.currentThread().getName());
        while (true){
            System.out.println("运行线程"+Thread.currentThread().getName()+"，输出i的值为："+i);
            try {
                Thread.sleep(10);
            }catch (InterruptedException e){
                System.out.println(e.getMessage());
            }

           if (i==4)break;
           i++;
        }
        System.out.println(Thread.currentThread().getName()+"运行结束");
    }
}
